/*	@brief	:	guard for threads
*	@author	:	yangcancheng
*	@date	:	2009-08-04
*/

#ifndef _CTHREAD_GUARD_H_
#define _CTHREAD_GUARD_H_

#include "mutex.h"

namespace CThread
{

class Guard
{
public:
	Guard(Mutex& mutex) : _mutex(mutex) 
	{
		_mutex.lock();
	}
	
	~Guard()
	{
		_mutex.unlock();
	}

private:
	Mutex& _mutex;
};

};

#endif // #ifndef _CTHREAD_GUARD_H_
